package com.ruoyi.system.service.impl;

import java.util.Date;
import java.util.List;

import com.ruoyi.system.domain.SysHouseholdTask;
import com.ruoyi.system.mapper.SysHouseholdMapper;
import com.ruoyi.system.mapper.SysHouseholdTaskMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysOvertimeMapper;
import com.ruoyi.system.domain.SysOvertime;
import com.ruoyi.system.service.ISysOvertimeService;

/**
 * 核酸超时管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-10-17
 */
@Service
public class SysOvertimeServiceImpl implements ISysOvertimeService
{
    @Autowired
    private SysHouseholdTaskMapper sysHouseholdTaskMapper;

    @Autowired
    private SysHouseholdMapper sysHouseholdMapper;

    @Autowired
    private SysOvertimeMapper sysOvertimeMapper;

    /**
     * 查询核酸超时管理
     * 
     * @param id 核酸超时管理主键
     * @return 核酸超时管理
     */
    @Override
    public SysOvertime selectSysOvertimeById(Long id)
    {
        return sysOvertimeMapper.selectSysOvertimeById(id);
    }

    /**
     * 查询核酸超时管理列表
     * 
     * @param sysOvertime 核酸超时管理
     * @return 核酸超时管理
     */
    @Override
    public List<SysOvertime> selectSysOvertimeList(SysOvertime sysOvertime)
    {
        Integer i = 0;
        List<SysHouseholdTask> list = sysHouseholdTaskMapper.selectIncompleteTaskList(i);
        for (SysHouseholdTask sht:list) {
            String task = sht.getTask();
            Long community = sht.getCommunity();
            Long building = sht.getBuilding();
            String name = sht.getName();
            Date createTime = sht.getCreateTime();
            Date outTime = sht.getOutTime();

            SysOvertime overtime = new SysOvertime();
            overtime.setTask(task);
            overtime.setCommunity(community);
            overtime.setBuilding(building);
            overtime.setState("未检测");
            overtime.setName(name);
            overtime.setOntime(createTime);
            overtime.setOuttime(outTime);
            sysOvertimeMapper.insertSysOvertime(overtime);
        }
        return sysOvertimeMapper.selectSysOvertimeList(sysOvertime);
    }

    /**
     * 新增核酸超时管理
     * 
     * @param sysOvertime 核酸超时管理
     * @return 结果
     */
    @Override
    public int insertSysOvertime(SysOvertime sysOvertime)
    {
        return sysOvertimeMapper.insertSysOvertime(sysOvertime);
    }

    /**
     * 修改核酸超时管理
     * 
     * @param sysOvertime 核酸超时管理
     * @return 结果
     */
    @Override
    public int updateSysOvertime(SysOvertime sysOvertime)
    {
        return sysOvertimeMapper.updateSysOvertime(sysOvertime);
    }

    /**
     * 批量删除核酸超时管理
     * 
     * @param ids 需要删除的核酸超时管理主键
     * @return 结果
     */
    @Override
    public int deleteSysOvertimeByIds(Long[] ids)
    {
        return sysOvertimeMapper.deleteSysOvertimeByIds(ids);
    }

    /**
     * 删除核酸超时管理信息
     * 
     * @param id 核酸超时管理主键
     * @return 结果
     */
    @Override
    public int deleteSysOvertimeById(Long id)
    {
        return sysOvertimeMapper.deleteSysOvertimeById(id);
    }
}
